package com.estate.struts.actions;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.apache.struts2.ServletActionContext;
import org.jmesa.web.HttpServletRequestWebContext;
import org.jmesa.web.WebContext;
import org.jmesa.worksheet.Worksheet;
import org.jmesa.worksheet.WorksheetRow;
import org.jmesa.worksheet.state.SessionWorksheetState;
import org.jmesa.worksheet.state.WorksheetState;

import com.opensymphony.xwork2.ActionSupport;

public class TestCheckboxAction extends ActionSupport {
	
	private String[] up;
	
	@Override
	public String execute() throws Exception {
		System.out.println("test checkbox success");
		System.out.println("up =============== " + this.up);
		String page = "";
		WebContext webContext = new HttpServletRequestWebContext(ServletActionContext.getRequest());
		WorksheetState state = new SessionWorksheetState("user_table", webContext);
		
		Worksheet worksheet = state.retrieveWorksheet();
		Collection<WorksheetRow> rows = worksheet.getRows();
		System.out.println("row size ========= " + rows.size());
		List<Long> ids = new ArrayList<Long>();
		  for (WorksheetRow row : rows) {
			  System.out.println(row.getUniqueProperty().getValue());
		       ids .add(Long.parseLong(row.getUniqueProperty().getValue()));
		  }
		return this.SUCCESS;
	}

	public String[] getUp() {
		return up;
	}

	public void setUp(String[] up) {
		this.up = up;
	}
}